﻿using NPOI.SS.UserModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ExcelToChart
{
    public partial class Form1 : Form
    {
        public void myPartialFunction()
        {
            Console.WriteLine("myPartialFunction run ok");
        }
    }

    public static class Util
    {
        public static DateTime GuessMonth(string str)
        {
            DateTime dt = new DateTime();

            return dt;
        }
    }

    public class SheetDataTable : DataTable
    {
        public DateTime YearMonth { get; set; }

        public DataGridView dataGridView { get; set; }

        public int dateColumnIndex { get; set; }

        public int numberColumnIndex { get; set; }

        public Dictionary<int, int> rowToDayNumberMapping { get; set; }

        public SheetDataTable(ISheet npoiSheet)
        {
            this.TableName = npoiSheet.SheetName;
        }

        public DataTable formatedTable 
        { 
            get
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("Date");
                dt.Columns.Add("Number");

                foreach(int k in rowToDayNumberMapping.Keys)
                {
                    DataRow dr = dt.NewRow();
                    dr["Date"] = string.Format("{0}-{1}-{2}", YearMonth.Year, YearMonth.Month, rowToDayNumberMapping[k]);
                    dr["Number"] = this.Rows[k][numberColumnIndex];
                }
                return dt;
            }
        }


    }
}
